package cc.yiueil.service.impl;

import cc.yiueil.entity.UserEntity;
import cc.yiueil.mapper.UserMapper;
import cc.yiueil.service.UserService;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class UserServiceImpl implements UserService {
    private final UserMapper userMapper;

    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserEntity userEntity = userMapper.getUserByLoginName(username);
        List<String> functionRightName = new ArrayList<>();
        functionRightName.add("ROLE_USER");
        userEntity.setFunctionRightName(functionRightName);
        return userEntity;
    }
}
